#pragma once

#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <fstream>

using namespace std;

enum Rating
{
	UNRATED = -1,
	G,
	PG,
	PG13,
	R,
	NC17
};

const string RATING_WORDS[] = { "G", "PG", "PG-13", "R", "NC-17" };  

class Movie
{
public:
	//default constructor
	Movie();
	//constructor
	Movie( const string& name, Rating rating, int budget, int revenue );
	Movie( const string& name, Rating rating, int budget, int revenue, string reviewFileLoc );
	//destructor
	~Movie(){};

	string formatReport();//return a string with all the info for the movie
	int getTotalProfit() { return mRevenue - mBudget; }
	float getEarningsPerDollarInvested() { return getTotalProfit() / (float)mRevenue; }//calculate and return profit divided by revenue
	string getRatingName();//return the string which correlates with the rating
	friend ostream& operator<<(ostream& out, Movie& mov);

	//reads the associated reviews file and loads all review data
	void loadReviews();
	//add a review
	void addReview( int numStars );
	//get how many reviews for a given number of stars
	int getNumReviews( int numStars );
	//get the average number of stars
	float getAverageReview();

	//accessors
	string getName(){ return mName; };
	Rating getRating(){ return mRating; };
	int getBudget(){ return mBudget; };
	int getRevenue(){ return mRevenue; };

private:
	string mName;//name of the movie
	Rating mRating;//the rating of the movie (Rating is an enumerated type)
	int mBudget;//how much the movie cost to make/market/distribute
	int mRevenue;//how much the movie earned in revenue from all sources
	vector<int> mReviews;//Vector of star reviews
	string mReviewFileLoc;
};
